package br.com.dev.tcc.view.dialog;

import android.app.Dialog;
import android.content.Context;
import android.view.View;
import android.view.Window;
import br.com.dev.tcc.R;
import br.com.dev.tcc.bean.Apolice;

public class ApolicesDialog extends Dialog {

	private Apolice apolice;

	private OnRemoveListener listenerRemove;

	private View containerAcoes;
	private View botaoVoltar;
	private View containerPergunta;
	private View botaoConfirmar;

	private OnBuscaSinistroListener listenerBusca;

	public ApolicesDialog(final Context context, Apolice apolice) {

		super(context, R.style.DialogAppTheme);
		this.apolice = apolice;

		super.getWindow();
		super.requestWindowFeature(Window.FEATURE_NO_TITLE);
		super.setContentView(R.layout.apolices_dialog);

		containerAcoes = findViewById(R.id.container);
		botaoVoltar = findViewById(R.id.btBack);
		containerPergunta = findViewById(R.id.containerPergunta);
		botaoConfirmar = findViewById(R.id.btConfirm);

		botaoVoltar.setOnClickListener(new View.OnClickListener() {

			@Override
			public void onClick(View v) {
				dismiss();
			}
		});

		findViewById(R.id.tvSinistro).setOnClickListener(
				new View.OnClickListener() {

					@Override
					public void onClick(View v) {
						listenerBusca.onBusca(ApolicesDialog.this.apolice);
						dismiss();
					}
				});

		findViewById(R.id.tvExcluir).setOnClickListener(
				new View.OnClickListener() {

					@Override
					public void onClick(View v) {

						containerAcoes.setVisibility(View.GONE);
						containerPergunta.setVisibility(View.VISIBLE);
					}
				});

		botaoConfirmar.setOnClickListener(new View.OnClickListener() {

			@Override
			public void onClick(View v) {
				listenerRemove.onRemove(ApolicesDialog.this.apolice);
				dismiss();
			}
		});
	}

	public void setOnRemoveListener(OnRemoveListener listener) {
		this.listenerRemove = listener;
	}

	public void setOnBuscaListener(OnBuscaSinistroListener listener) {
		listenerBusca = listener;
	}

	public interface OnRemoveListener {
		public void onRemove(Apolice apolice);
	}

	public interface OnBuscaSinistroListener {
		public void onBusca(Apolice apolice);
	}
}
